package com.scoy.honeymei.adapter.tabadapter;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

/**
 * @ClassName: TabFragmentAdapter$
 * @Description: tab vp 适配器
 * @Author: GaoZhan
 * @CreateDate: 2019/6/18/0018$ 下午 17:52$
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/6/18/0018$ 下午 17:52$
 * @UpdateRemark: 更新内容
 */
public class TabFragmentAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragments;
    private String[] mTitles;

    public TabFragmentAdapter(FragmentManager fm, List<Fragment> fragments, String[] mTitles) {
        super(fm, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.fragments = fragments;
        this.mTitles = mTitles;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
